package geometry;

import java.util.ArrayList;
import java.util.List;

import foundationgeom.Transformation;
import foundationgeom.Vector;
import graph.GNode;

public final class GeomMatcher {
	
    public static List<GeomMatch> findGeomMatches(Geometry lhsGeometry, Geometry designGeometry) {
		List<GeomMatch> completeMatches = new ArrayList<GeomMatch>();
        GeomMatch match = new GeomMatch();
        if (!((GNode) lhsGeometry).hasSubsetOfLabels((GNode) designGeometry)) {
            return completeMatches;
        }
        
        if (lhsGeometry.getClass() != designGeometry.getClass()) {
            return completeMatches;
        }

        Transformation transformation = lhsGeometry.getTransformation(designGeometry);
        Vector scale = lhsGeometry.getScale(designGeometry);
        Transform transform = new Transform(transformation, scale);
        match.put(lhsGeometry, designGeometry);
        match.setTransform(transform);
    
	    boolean valid = validateTransformation(lhsGeometry, designGeometry, match);
	    if (valid) {
	        completeMatches.add(match);
	    }
		return completeMatches;
	}

    private static boolean validateTransformation(Geometry lhsGeometry,
            Geometry designGeometry, GeomMatch match) {
        
        //FIXME - this assumes that no geometry is a multi-part geometry
        return true;
    }
}
